import os
import uiautomation
from config.config import DATA_PATH
from page.index import IndexPage
from page.门诊医生站.门诊医生站.SOAP__page import SOAP
from page.门诊医生站.门诊医生站.feiyaowuchufang__page import Feiyaowuchufang
from page.门诊医生站.门诊医生站.jianchajianyan__page import Jianchajianyan
from page.门诊医生站.门诊医生站.menzhenyishengzhan__page import menzhenyishengzhan
from page.门诊医生站.门诊医生站.xiyaochengyaochufang__page import Xiyaochengyaochufang
from page.门诊医生站.门诊医生站.zhongyaochufang__page import Zhongyaochufang
from tools.add_xiangmushuju import add_xiangmu
from tools.sjqd_way import read_data_from_excel
class Menzhenyishengzhan():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    def menzhenyishengzhan(self):
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "测试患者")
        name = self.data[0][0]
        ap = IndexPage()
        bp = menzhenyishengzhan()
        cp = SOAP()
        dp = Xiyaochengyaochufang()
        ep = Zhongyaochufang()
        fp = Feiyaowuchufang()
        gp = Jianchajianyan()
        ap.click_mzysz1_btn()
        ap.click_mzysz_btn()
        bp.click_dendai_btn()#点击等待
        bp.click_yifuwu_btn()#点击以服务
        bp.click_quanbubingren_btn()#点击全部病人
        bp.input_name(name)#输入患者名字
        bp.click_shuaxin_btn()#点击刷新
        bp.double_click_huanzhe_btn()#双击患者
        cp.click_SOAP_btn()#点击SOAP
        cp.choose_zdjg_btn()#选择诊断
        dp.click_xycycf_btn()#点击西药成药处方
        bp.add_xinzu(1)#添加5个新组
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "西药成药处方")
        ypmc_xy1,cs_xy1,yf_xy1= self.data[0]
        dp.input_xy1(ypmc_xy1,cs_xy1,yf_xy1)
        dp.choose_ps1()#点击皮试1
        ypmc_xy2, cs_xy2, yf_xy2 = self.data[1]
        dp.input_xy2(ypmc_xy2, cs_xy2, yf_xy2)
        ep.click_zycf_btn()#点击中药处方
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "中药处方")
        print(self.data[0])
        ypmc_zy1, cs_zy1, yf_zy1 = self.data[0]
        ep.input_zy1(ypmc_zy1, cs_zy1, yf_zy1)
        gp.click_jianyanjiancha_btn()
        add_xiangmu(1)#添加1条数据项
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "检验检查")
        xmmc1 = self.data[2][0]
        gp.choose_jyjc_xmmc1(xmmc1)
        bp.click_savebtn()#点击保存
        bp.click_ts_ok()#点击确定按钮
        bp.click_yl_close()#点击预览关闭


if __name__ == '__main__':
  Menzhenyishengzhan().menzhenyishengzhan()
